package jvmtest;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

/**
 * @author Jim
 * @date 8:05 下午 2022/4/2
 * @description 需饮用
 * @email:huwmz04153277@126.com
 */
public class Phan {
    public static void main(String[] args) throws Exception{
        Test t = new Test();
        ReferenceQueue queue = new ReferenceQueue();
        PhantomReference<Test> phantomReference = new PhantomReference<Test>(new Test(),queue);
 //       t = null;
        System.gc();
        Thread.sleep(30);
        System.out.printf("Gc");
        System.err.println(queue.poll());
    }

}
